//
//  TicketCenterViewTableViewCell.m
//  customer
//
//  Created by Holothurian on 2018/11/6.
//  Copyright © 2018年 yinlong. All rights reserved.
//

#import "TicketCenterViewTableViewCell.h"

@interface TicketCenterViewTableViewCell()

/**
 订单号：
 */
@property (nonatomic,strong)UILabel *orderLabel;

/**
 //订单状态 0 待处理 1已处理
 */
@property (nonatomic,strong)UILabel *invoice_StateLabel;

/**
  发票类型： 1:个人 2:公司
 */
@property (nonatomic,strong)UILabel *invoice_TypeLabel;

/**
 发票/抬头内容
 */
@property (nonatomic,strong)UILabel *invoice_NameLabel;

/**
 💰298
 */
@property (nonatomic,strong)UILabel *order_priceLabel;

@end

@implementation TicketCenterViewTableViewCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        AutoWeakSelf
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        _orderLabel = [[UILabel alloc]init];
        _orderLabel.text = @"订单号：";
        _orderLabel.font = Font(14);
        _orderLabel.userInteractionEnabled = YES;
        _orderLabel.textColor = [HSPublic colorWithHexString:@"333333"];
        [self.contentView addSubview:_orderLabel];
        [_orderLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(weakSelf.contentView).offset(15);
            make.top.equalTo(weakSelf.contentView).offset(10);
            make.size.mas_equalTo(CGSizeMake(F_DEVICE_W - 120, 30));
        }];
        
        _invoice_StateLabel = [[UILabel alloc]init];
        _invoice_StateLabel.font = Font(12);
        _invoice_StateLabel.textAlignment = NSTextAlignmentRight;
        _invoice_StateLabel.textColor = [HSPublic colorWithHexString:@"#D51A28"];
        _invoice_StateLabel.userInteractionEnabled = YES;
        [self.contentView addSubview:_invoice_StateLabel];
        [_invoice_StateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(weakSelf.contentView).offset(-15);
            make.top.equalTo(weakSelf.contentView).offset(10);
            make.size.mas_equalTo(CGSizeMake(60, 30));
        }];
        
        _invoice_TypeLabel = [[UILabel alloc]init];
        _invoice_TypeLabel.text = @"发票类型：";
        _invoice_TypeLabel.font = Font(10);
        _invoice_TypeLabel.textColor = [HSPublic colorWithHexString:@"#B5B4B4"];
        _invoice_TypeLabel.userInteractionEnabled = YES;
        [self.contentView addSubview:_invoice_TypeLabel];
        [_invoice_TypeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(weakSelf.contentView).offset(20);
            make.top.equalTo(weakSelf.orderLabel.mas_bottom).offset(10);
            make.size.mas_equalTo(CGSizeMake(F_DEVICE_W - 120, 20));
        }];
        
        _invoice_NameLabel = [[UILabel alloc]init];
        _invoice_NameLabel.font = Font(10);
        _invoice_NameLabel.text = @"发票内容：";
        _invoice_NameLabel.textColor = [HSPublic colorWithHexString:@"#B5B4B4"];
        _invoice_NameLabel.userInteractionEnabled = YES;
        [self.contentView addSubview:_invoice_NameLabel];
        [_invoice_NameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(weakSelf.contentView).offset(20);
            make.top.equalTo(weakSelf.invoice_TypeLabel.mas_bottom).offset(5);
            make.size.mas_equalTo(CGSizeMake(F_DEVICE_W - 120, 20));
        }];
        
        UIView *lineView = [[UIView alloc]init];
        lineView.backgroundColor = [HSPublic colorWithHexString:@"#979797"];
        lineView.alpha = 0.5;
        [self.contentView addSubview:lineView];
        [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(weakSelf.invoice_NameLabel.mas_bottom).offset(5);
            make.left.right.equalTo(weakSelf.contentView);
            make.height.mas_offset(1);
        }];
        
        _order_priceLabel = [[UILabel alloc]init];
        _order_priceLabel.text = @"开票金额：";
        _order_priceLabel.font = Font(12);
        _order_priceLabel.textColor = [HSPublic colorWithHexString:@"D51A28"];
        _order_priceLabel.userInteractionEnabled = YES;
        [self.contentView addSubview:_order_priceLabel];
        [_order_priceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(weakSelf.contentView).offset(15);
            make.top.equalTo(lineView).offset(10);
            make.size.mas_equalTo(CGSizeMake(F_DEVICE_W - 120, 30));
        }];
      
    }
    return self;
}

- (void)cellForLayoutTicketCell:(TicketBaseModel *)model{
    self.orderLabel.text = [NSString stringWithFormat:@"订单号：%@",model.order_no];
    self.invoice_StateLabel.text = model.invoice_state_show?:@"";
    self.invoice_TypeLabel.text = [NSString stringWithFormat:@"发票类型：%@",model.invoice_type_show];
    self.invoice_NameLabel.text = @"发票内容：技术费";
    self.order_priceLabel.text = [NSString stringWithFormat:@"开票金额：¥%@",model.order_price];
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end

/**
 发票已开票
 2008.4.4 2:33
 */
@implementation TicketDetailSubtitleTableCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        AutoWeakSelf
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        _nameLabel = [[UILabel alloc]init];
        _nameLabel.font = Font(16);
        _nameLabel.textColor = [HSPublic colorWithHexString:@"333333"];
        [self.contentView addSubview:_nameLabel];
        [_nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(weakSelf.contentView).offset(30);
            make.top.equalTo(weakSelf.contentView).offset(0);
            make.size.mas_equalTo(CGSizeMake(F_DEVICE_W - 60, 25));
        }];
        
        _subTitleLabel = [[UILabel alloc]init];
        _subTitleLabel.font = Font(12);
        _subTitleLabel.textColor = [HSPublic colorWithHexString:@"999999"];
        [self.contentView addSubview:_subTitleLabel];
        [_subTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(weakSelf.contentView).offset(30);
            make.top.equalTo(weakSelf.nameLabel.mas_bottom).offset(0);
            make.size.mas_equalTo(CGSizeMake(F_DEVICE_W - 60, 20));
        }];
    }
    return self;
}

@end


/**
 订单编号  20185522564676
 */

@implementation TicketDetailDefaultTableCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        AutoWeakSelf
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        _nameLabel = [[UILabel alloc]init];
        _nameLabel.text = @"订单编号";
        _nameLabel.font = Font(14);
        _nameLabel.textColor = [HSPublic colorWithHexString:@"#999999"];
        [self.contentView addSubview:_nameLabel];
        [_nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(weakSelf.contentView).offset(30);
            make.top.equalTo(weakSelf.contentView).offset(10);
            make.size.mas_equalTo(CGSizeMake(80, 30));
        }];
        
        _subTitleLabel = [[UILabel alloc]init];
        _subTitleLabel.font = Font(12);
        _subTitleLabel.textAlignment = NSTextAlignmentLeft;
        _subTitleLabel.textColor = [HSPublic colorWithHexString:@"#333333"];
        [self.contentView addSubview:_subTitleLabel];
        [_subTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(weakSelf.nameLabel.mas_right).offset(10);
            make.top.equalTo(weakSelf.contentView).offset(10);
            make.size.mas_equalTo(CGSizeMake(F_DEVICE_W - 130, 30));
        }];
    }
    return self;
}

- (void)cellRemarkForOrderDetailServiceTimeUse{
    AutoWeakSelf
    [_nameLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.contentView).offset(20);
        make.top.equalTo(weakSelf.contentView).offset(5);
        make.size.mas_equalTo(CGSizeMake(80, 40));
    }];
    [_subTitleLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf.contentView).mas_offset(5);
        make.right.equalTo(weakSelf.contentView).offset(-10);
        make.size.mas_equalTo(CGSizeMake(F_DEVICE_W - 130, 40));
    }];
    self.subTitleLabel.numberOfLines = 0;
    self.subTitleLabel.textAlignment = NSTextAlignmentRight;
    self.nameLabel.textColor = [UIColor blackColor];
    self.subTitleLabel.textColor = [HSPublic colorWithHexString:@"#333333"];
    self.contentView.backgroundColor = [HSPublic colorWithHexString:@"FDFBEF"];
}

- (void)cellReLayoutForOrderDetialChargeCell{
    AutoWeakSelf
    [_nameLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.contentView).offset(20);
        make.top.equalTo(weakSelf.contentView).offset(5);
        make.size.mas_equalTo(CGSizeMake(F_DEVICE_W / 2.0 - 30, 40));
    }];
    [_subTitleLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf.contentView).mas_offset(10);
        make.right.equalTo(weakSelf.contentView).offset(-10);
        make.size.mas_equalTo(CGSizeMake(F_DEVICE_W / 2.0 - 20, 30));
    }];
    self.nameLabel.textColor = [UIColor blackColor];
    self.subTitleLabel.textAlignment = NSTextAlignmentRight;
    self.subTitleLabel.textColor = [HSPublic colorWithHexString:@"#DA3924"];
    self.contentView.backgroundColor = [UIColor whiteColor];
}

- (void)cellForTicketCell{
    AutoWeakSelf
    [_nameLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.contentView).offset(15);
        make.top.equalTo(weakSelf.contentView).offset(5);
        make.size.mas_equalTo(CGSizeMake(70, 40));
    }];
    [_subTitleLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf.contentView).mas_offset(10);
        make.right.equalTo(weakSelf.contentView).offset(-10);
        make.size.mas_equalTo(CGSizeMake(F_DEVICE_W - 100, 30));
    }];
    self.subTitleLabel.textAlignment = NSTextAlignmentLeft;
}

@end
/**
 发票信息 个人
 */
@interface TicketDetailPersonInfoTableCell()



@end

@implementation TicketDetailPersonInfoTableCell



@end

/**
 发票信息 企业
 */
@interface TicketDetailCompanyInfoTableCell()

/**
 发票抬头
 */
@property (nonatomic,strong)UILabel *ticketNameLabel;

/**
 税号
 */
@property (nonatomic,strong)UILabel *ticketNumberLabel;

/**
 发票内容
 */
@property (nonatomic,strong)UILabel *ticketContentLabel;

/**
 发票金额
 */
@property (nonatomic,strong)UILabel *ticketPriceLabel;

/**
 申请时间
 */
@property (nonatomic,strong)UILabel *applyTimeLabel;

/**
 //公司名称
 */
@property (nonatomic,strong)UILabel *invoice_company_nameLabel;

/**
 税号
 */
@property (nonatomic,strong)UILabel *invoice_noLabel;

/**
 发票内容
 */
@property (nonatomic,strong)UILabel *invoice_nameLabel;

/**
 发票金额
 */
@property (nonatomic,strong)UILabel *order_priceLabel;

/**
 申请时间
 */
@property (nonatomic,strong)UILabel *create_timeLabel;

@end

@implementation TicketDetailCompanyInfoTableCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        AutoWeakSelf
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        _ticketNameLabel = [[UILabel alloc]init];
        _ticketNameLabel.text = @"发票抬头";
        _ticketNameLabel.textColor = [HSPublic colorWithHexString:@"#999999"];
        _ticketNameLabel.font = Font(14);
        [self.contentView addSubview:_ticketNameLabel];
        [_ticketNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(weakSelf.contentView).offset(10);
            make.left.equalTo(weakSelf.contentView).offset(30);
            make.size.mas_equalTo(CGSizeMake(80, 25));
        }];
        
        _invoice_company_nameLabel = [[UILabel alloc]init];
        _invoice_company_nameLabel.font = Font(12);
        _invoice_company_nameLabel.textColor = [HSPublic colorWithHexString:@"#333333"];
        [self.contentView addSubview:_invoice_company_nameLabel];
        [_invoice_company_nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(weakSelf.ticketNameLabel.mas_right).offset(10);
            make.top.equalTo(weakSelf.contentView).offset(10);
            make.size.mas_equalTo(CGSizeMake(F_DEVICE_W - 130, 25));
        }];
        UIView *line1 = [[UIView alloc]initWithFrame:CGRectMake(15, 45, F_DEVICE_W - 30, 1)];
        line1.backgroundColor = [HSPublic colorWithHexString:@"#CCCCCC"];
        [self.contentView addSubview:line1];
        
        _ticketNumberLabel = [[UILabel alloc]init];
        _ticketNumberLabel.text = @"税号";
        _ticketNumberLabel.textColor = [HSPublic colorWithHexString:@"#999999"];
        _ticketNumberLabel.font = Font(14);
        [self.contentView addSubview:_ticketNumberLabel];
        [_ticketNumberLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(line1.mas_bottom).offset(10);
            make.left.equalTo(weakSelf.contentView).offset(30);
            make.size.mas_equalTo(CGSizeMake(80, 25));
        }];
        
        _invoice_noLabel = [[UILabel alloc]init];
        _invoice_noLabel.font = Font(12);
        _invoice_noLabel.textColor = [HSPublic colorWithHexString:@"#333333"];
        [self.contentView addSubview:_invoice_noLabel];
        [_invoice_noLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(weakSelf.ticketNumberLabel.mas_right).offset(10);
            make.top.equalTo(weakSelf.ticketNumberLabel);
            make.size.mas_equalTo(CGSizeMake(F_DEVICE_W - 130, 25));
        }];
        UIView *line2 = [[UIView alloc]initWithFrame:CGRectMake(15, 90, F_DEVICE_W - 30, 1)];
        line2.backgroundColor = [HSPublic colorWithHexString:@"#CCCCCC"];
        [self.contentView addSubview:line2];
        
        _ticketContentLabel = [[UILabel alloc]init];
        _ticketContentLabel.text = @"发票内容";
        _ticketContentLabel.textColor = [HSPublic colorWithHexString:@"#999999"];
        _ticketContentLabel.font = Font(14);
        [self.contentView addSubview:_ticketContentLabel];
        [_ticketContentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(line2.mas_bottom).offset(10);
            make.left.equalTo(weakSelf.contentView).offset(30);
            make.size.mas_equalTo(CGSizeMake(80, 25));
        }];
        
        _invoice_nameLabel = [[UILabel alloc]init];
        _invoice_nameLabel.font = Font(12);
        _invoice_nameLabel.textColor = [HSPublic colorWithHexString:@"#333333"];
        [self.contentView addSubview:_invoice_nameLabel];
        [_invoice_nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(weakSelf.ticketContentLabel.mas_right).offset(10);
            make.top.equalTo(weakSelf.ticketContentLabel);
            make.size.mas_equalTo(CGSizeMake(F_DEVICE_W - 130, 25));
        }];
        UIView *line3 = [[UIView alloc]initWithFrame:CGRectMake(15, 135, F_DEVICE_W - 30, 1)];
        line3.backgroundColor = [HSPublic colorWithHexString:@"#CCCCCC"];
        [self.contentView addSubview:line3];
        
        _ticketPriceLabel = [[UILabel alloc]init];
        _ticketPriceLabel.text = @"发票金额";
        _ticketPriceLabel.textColor = [HSPublic colorWithHexString:@"#999999"];
        _ticketPriceLabel.font = Font(14);
        [self.contentView addSubview:_ticketPriceLabel];
        [_ticketPriceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(line3.mas_bottom).offset(10);
            make.left.equalTo(weakSelf.contentView).offset(30);
            make.size.mas_equalTo(CGSizeMake(80, 25));
        }];
        
        _order_priceLabel = [[UILabel alloc]init];
        _order_priceLabel.font = Font(12);
        _order_priceLabel.textColor = [HSPublic colorWithHexString:@"#333333"];
        [self.contentView addSubview:_order_priceLabel];
        [_order_priceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(weakSelf.ticketPriceLabel.mas_right).offset(10);
            make.top.equalTo(weakSelf.ticketPriceLabel);
            make.size.mas_equalTo(CGSizeMake(F_DEVICE_W - 130, 25));
        }];
        UIView *line4 = [[UIView alloc]initWithFrame:CGRectMake(15, 180, F_DEVICE_W - 30, 1)];
        line4.backgroundColor = [HSPublic colorWithHexString:@"#CCCCCC"];
        [self.contentView addSubview:line4];
        
        
        _applyTimeLabel = [[UILabel alloc]init];
        _applyTimeLabel.text = @"申请时间";
        _applyTimeLabel.textColor = [HSPublic colorWithHexString:@"#999999"];
        _applyTimeLabel.font = Font(14);
        [self.contentView addSubview:_applyTimeLabel];
        [_applyTimeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(line4.mas_bottom).offset(10);
            make.left.equalTo(weakSelf.contentView).offset(30);
            make.size.mas_equalTo(CGSizeMake(80, 25));
        }];
        
        _create_timeLabel = [[UILabel alloc]init];
        _create_timeLabel.font = Font(12);
        _create_timeLabel.textColor = [HSPublic colorWithHexString:@"#333333"];
        [self.contentView addSubview:_create_timeLabel];
        [_create_timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(weakSelf.applyTimeLabel.mas_right).offset(10);
            make.top.equalTo(weakSelf.applyTimeLabel);
            make.size.mas_equalTo(CGSizeMake(F_DEVICE_W - 130, 25));
        }];
    }
    return self;
}

- (void)cellForLayoutCompanyCell:(TicketBaseModel *)model{
    if ([model.invoice_type isEqualToString:@"1"]) {
        self.invoice_company_nameLabel.text = model.invoice_name?:@"";
    }else{
        self.invoice_company_nameLabel.text = model.invoice_company_name?:@"";
    }
    self.invoice_noLabel.text = model.invoice_no?:@"";
    self.invoice_nameLabel.text = @"技术费";
    self.order_priceLabel.text = model.order_price?:@"";
    self.create_timeLabel.text = model.create_time?:@"";
}

@end
